import { studentApi, teacherApi } from '@/services/api-common';
import Add from '../components/AddEdit/Add.js';
import { $TableTabs } from '@/.jiess';
import items1 from './items1.js';
import items2 from './items2.js';

function setup() {
	this.add(
		this.render({
			is: $TableTabs,
			tables: [{
				items: items1,
				tabTitle: '学生信息',
				httpApi: async (param) => {
					if (param.age === 0) param.age = null;
					return await studentApi.list(param)
				},
				httpKey: studentApi.listKey,
				container(midder) {
					return {
						title: '学生列表',
						extra: this.render({
							midder,
							is: 'TableTools',
							buttons: [{
								type: 'primary',
								text: '新增',
								onClick: () => {
									midder.open(Add, studentApi.add, 'add', {
										param: { class: 'no-padding' }
									})
								}
							}]
						})
					}
				},
				filter(midder) {
					return this.render({ is: 'ExpandFilter', midder })
				},
			}, {
				items: items2,
				tabTitle: '老师信息',
				httpApi: async (param) => {
					if (param.age === 0) param.age = null;
					return await teacherApi.list(param)
				},
				httpKey: teacherApi.listKey,
				container(midder) {
					return {
						title: '老师列表',
						extra: this.render({
							midder,
							is: 'TableTools',
							buttons: [{
								type: 'primary',
								text: '新增',
								onClick: () => {
									midder.open(Add, teacherApi.add, 'add', {
										param: { class: 'no-padding' }
									})
								}
							}]
						})
					}
				},
				filter(midder) {
					return this.render({
						is: 'TableFilter',
						title: '筛选区2',
						midder
					})
				},
			}]
		})
	)
}
export default setup;